package com.study.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import java.util.Calendar;

@Controller
public class HelloController {


    @GetMapping("/toLoginPage")
    public  String hello(Model model){

        model.addAttribute("currentYear", Calendar.getInstance().get(Calendar.YEAR));
        return "login";
    }

    @GetMapping("/login")
    public  String login(Model model, HttpServletRequest request){

        System.out.println("login进入");
        String username = request.getParameter("username");

        System.out.println(username);



        model.addAttribute("username",username);
        return "index";

    }
}
